package com.stgy.lease.common.config;

import com.stgy.lease.common.converter.BaseTypeEnumConverterFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName:STGYWebConfigration
 * Package:com.stgy.lease.common.config
 * Description:WebMvcConfigurer：springmvc提供 用来动态组件类 或者 动态配置 配置类
 *
 * @Author:helei
 * @Create:2024/8/30 - 10:50
 */
@Configuration
public class STGYWebConfigration implements WebMvcConfigurer {

    //1、注册springmvc拦截器的方法
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor()
//                .addPathPatterns()
//    }


    //2、springmvc提供的跨域配置
//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
////        WebMvcConfigurer.super.addCorsMappings(registry);
//        registry.addMapping()
//                .
//    }


    @Autowired
    private BaseTypeEnumConverterFactory baseTypeEnumConverterFactory;
    //3、springmvc 提供的 注册 参数转换器配置
    @Override
    public void addFormatters(FormatterRegistry registry) {
        //WebMvcConfigurer.super.addFormatters(registry);
//        registry.addConverter(); 注册单个转换器
        //注册工厂
        registry.addConverterFactory(baseTypeEnumConverterFactory);
    }
}
